// 格式化帖子内容
export const formateContent = (str: any): string => {
  const regTopic = /&START&(\{#.*?})&END&/g;
  const regImg = /<sprite="EmojiAtlas" index=(\d+)>/g;
  function replaceTopic(match: string, captureGroup: any) {
    return `<span style="color: #4396ef">${captureGroup.slice(1, -1)}</span>`;
  }

  function replaceImg(match: string, captureGroup: any) {
    return `<img src="${getAssetsFile(`expression_${captureGroup}.png`)}" alt="" />`;
  }
  const strTopic = str.replace(regTopic, replaceTopic);
  return strTopic.replace(regImg, replaceImg);
};
const getAssetsFile = (url: string) => {
  return new URL(`../../assets/emoji/${url}`, import.meta.url).href;
};
